<template>
    <div>
        <h1>会员显示</h1>
        姓名 <input type="text" v-model="info.names">
        等级名称
        <select v-model="info.lievename">
                            <option value="">请选择</option>
                            <option :value="itme.Name" v-for="itme in list.a":key="itme.Id"> {{ itme.Name }}</option>
                        </select>
        金额 <input type="text" v-model="info.con">- <input type="text" v-model="info.end">
        <input type='button' value="查询" @click="getlists">
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>Id</td>
                    <td>编号</td>
                    <td>手机号</td>
                    <td>会员名称</td>
                    <td>会员身份证</td>
                    <td>等级名称</td>
                    <td>生日</td>
                    <td>性别</td>
                    <td>积分</td>
                    <td>余额</td>
                    <td>爱好</td>
                    <td>会员简介</td>
                    <td>修改时间</td>
                    <td>操作</td>
                </tr>

                <tr v-for="itme in data" :key="itme.Id">
                    <td>{{ itme.Id }}</td>
                    <td>{{ itme.Code }}</td>
                    <td>{{ itme.Phone }}</td>
                    <td>{{ itme.Name }}</td>
                    <td>{{ itme.Card }}</td>
                    <td>{{ itme.LevelName }}</td>
                    <td>{{ itme.BirthDay }}</td>
                    <td>{{ itme.Sex ?"男":"女"}}</td>
                    <td>{{ itme.Score }}</td>
                    <td>{{ itme.Money }}</td>
                    <td>{{ itme.Likes }}</td>
                    <td>{{ itme.Desc }}</td>
                    <td>{{ moment(itme.UpdateTime).format("YYYY-MM-DD HH:mm")  }}</td>
                    <td><input type='button' value="删除" class="btn btn-danger" @click="del(itme.Id)">
                        <input type='button' value="修改" class="btn btn-primary" @click="xg(itme.Id)">
                </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive, onMounted} from 'vue'
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';
import moment from 'moment';
const rouder=useRouter();
const roude=useRoute();
let info:any=reactive({
    names:'',
    lievename:'',
    con:'',
    end:''
})
let data:any=ref({
})

onMounted(()=>{
    getlist();
    getlists();
    
})
let list:any=reactive({
    a:[]
})
const getlist=()=>{
    axios({
        url:'/api/Hy/All',
        method:'get'
    })
    .then((res)=>{
        console.log(res);
        list.a=res.data;
    })
    .catch((err)=>{
        console.log(err);
        
    })

}
const getlists=()=>{
    axios({
        url:'/api/Hy/GetShow',
        method:'get',
        params:info
    })
    .then((res)=>{
        console.log(res);
        data.value=res.data
    })
    .catch((err)=>{
        console.log(err);
        
    })
}

//===================================修改
const xg=(Id:any)=>{
    rouder.push({
        path:'/xg',
        query:{Id:Id}
    })
}
//================================删除
const del=(id:any)=>{
    axios({
        url:'/api/Hy/GetDel',
        method:'delete',
        params:{id:id}
    })
    .then((res)=>{
        console.log(res);
         if(res.data>0)
    {
        alert('删除成功');
        getlists();
        return;
    }
    else
    {
        alert('删除失败');
        return;
    }
    })
    .catch((err)=>{
        console.log(err);
        
    })
}
</script>

<style scoped>

</style>